package org.example.Thread01;

public class Dome_Thread03 {
    //定义一个标志位
    static boolean isQuit=false;
    public static void main(String[] args) throws InterruptedException {
        Thread t1 = new Thread(()->{
            while(!isQuit){
                System.out.println("hello thread...");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println("线程结束...");
        });
        //启动线程
        t1.start();
        //休眠5秒
        Thread.sleep(5000);
        //更改标志位
        isQuit=true;
    }
}
